package org.example.game.history;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/26 11:03
 */
@Deprecated
public class Solution100326 {


    public String compressedString(String word) {

        List<String> subList= new ArrayList<>();

        int count = 0;
        char last = '0';
        for(Character c : word.toCharArray()){
            if(c != last){
                if(last != '0'){
                    subList.add(count + "" +  last);
                }
                count = 1;
                last = c;
            }else {
                count++;
                if(count == 9){
                    subList.add(count + "" +  last);
                    count = 0;
                    last = '0';
                }
            }
        }

        if(count > 0){
            subList.add(count + "" +  last);
        }

        String res = "";
        for(String sub : subList){
            res = res + sub;
        }
        return res;

    }


}
